package com.mas.session.state;

import jade.lang.acl.ACLMessage;

import com.mas.session.Session;
import com.thoughtworks.xstream.XStream;

/**
 * 
 * this class is being called only after new proposal from the other agent was
 * agreed and accept message should be sent. <br>
 * it tries to allocate the resources, if its succeeded, done message is being
 * sent, else failure message is sent.
 * 
 * @author Dudi & Efi
 * 
 */
public class AcceptNewProposalSenderState extends ExitState {

	public AcceptNewProposalSenderState(Session session) {
		super(session);
	}

	public void sendAcceptNewProposal(ACLMessage message) {

		

		ACLMessage reply = message.createReply();

		XStream xstream = new XStream();

		reply.setContent(xstream.toXML("Accepted"));
		reply.setPerformative(ACLMessage.ACCEPT_PROPOSAL);
		this.session.getAgent().send(reply);

		this.exit(message, "Proposal Accepted");
		session.setAccepted(true);
	}

	

	
	
}
